<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<f:view>
	<h:form id='new_item_form' method="POST" enctype="multipart/form-data">
		<head>
			<f:loadBundle basename="messages" var="msgs" />
			<title><h:outputText value="#{msgs.title}" /></title>

			<style type="text/css" title="currentStyle">
				@import "${facesContext.externalContext.requestContextPath}/views/management/css/item.css";
				@import "${facesContext.externalContext.requestContextPath}/views/css/theme.css";
			</style>
			
			<script type="text/javascript" src="${facesContext.externalContext.requestContextPath}/resources/script/jquery.js"></script>
			<script type="text/javascript"
				src="${facesContext.externalContext.requestContextPath}/views/management/scripts/create_item.js"></script>
				
			<script type="text/javascript">
					$(document).ready(function () {
					var flag = $('[id="new_item_form:item_flag"]' );
					var flagLabel = $('[id="new_item_form:flag_label"]' );
						flag.click(function(){
							if(flag.is(':checked'))
							{
								flagLabel.text("Disabled");
							}
							else
							{
								flagLabel.text("Enabled");
							}
						});
					})
		
			</script>

		</head>
		<body>
			<ui:include src="../header/header.xhtml" />

			<br />
			<br />
			<br />

			<h3><h:outputText value="#{msg.create_item_title}" /></h3>
			
			<div class="hidden_input">
				<h:inputText id="preview_icon" value="#{createItemBean.previewIconPath}"></h:inputText>
				<h:inputText id="temp_icon" value="#{createItemBean.tempIconFilePath}"></h:inputText>
				<h:inputText id="item_icon" value="#{createItemBean.icon}"></h:inputText>
			</div>

			<p></p>
			<div id="error_message" class="error">
			</div>


			<div id="div" class="item_form">
				<table class="display" id="item_table">
					<tr>
						<td><h:outputLabel value="#{msg.item_code}"></h:outputLabel></td>
						<td><h:inputText value="#{createItemBean.itemCode}" disabled="true">
							</h:inputText>
						</td>
						<td></td>
					</tr>
					
					<tr>
						<td><h:outputLabel value="#{msg.item_transaction_reference_number}"></h:outputLabel></td>
						<td>
							<h:inputText id="tran_ref_no" value="#{createItemBean.transactionReferenceNumber}" disabled="true">
							</h:inputText>
							<h:inputText id="tran_ref_no_hidden" class="hidden_input" value="#{createItemBean.transactionReferenceNumber}">
							</h:inputText>
							<h:inputText class="hidden_input" value="#{createItemBean.transactionReferenceNumber}">
							</h:inputText>
						</td>
						<td>
							<h:commandButton id="tr_btn" value="#{msg.item_transaction_reference_number}"
								action="#{createItemBean.openTransactionReferencesAction}">
							</h:commandButton>
						</td>
					</tr>

					<tr>
						<td>
							<h:outputLabel value="#{msg.item_name }">
							</h:outputLabel>
						</td>
						<td>
							<h:inputText id="item_name" value="#{createItemBean.itemName}">
							</h:inputText>
						</td>
						<td></td>
					</tr>

					<tr>
						<td><h:outputLabel value="#{msg.item_description}"></h:outputLabel></td>
						<td><h:inputTextarea id="item_description" value="#{createItemBean.itemDescription}"></h:inputTextarea></td>
						<td></td>
					</tr>

					<tr>
						<td><h:outputLabel value="#{msg.item_price }"></h:outputLabel></td>
						<td><h:inputText id="item_price" value="#{createItemBean.price}"></h:inputText></td>
						<td></td>
					</tr>
					
					<tr>
						<td><h:outputLabel value="Brand"></h:outputLabel>
						</td>
						<td>
							<h:inputText id="item_brand" value="#{createItemBean.brand}" disabled="true">
							</h:inputText>
							<h:inputText class="hidden_input" value="#{createItemBean.brand}">
							</h:inputText>
						</td>
						<td>
							<h:commandButton id="brand_btn" value="Brand"
								action="#{createItemBean.openBrandsAction}">
							</h:commandButton>
							</td>
					</tr>

					<tr>
						<td><h:outputLabel value="#{msg.item_orig_location}"></h:outputLabel>
						</td>
						<td>
							<h:inputText id="item_location" value="#{createItemBean.origLocation}" disabled="true">
							</h:inputText>
							<h:inputText class="hidden_input" value="#{createItemBean.origLocation}">
							</h:inputText>
						</td>
						<td>
							<h:commandButton id="location_btn" value="Location"
								action="#{createItemBean.openLocationsAction}">
							</h:commandButton>
							</td>
					</tr>

					<tr>
						<td><h:outputLabel value="#{msg.item_category}"></h:outputLabel></td>
						<td>
							<h:inputText id="item_category" value="#{createItemBean.category}" disabled="true"></h:inputText>
							<h:inputText class="hidden_input" value="#{createItemBean.category}"></h:inputText>
						</td>
						<td>
						<h:commandButton id="category_btn" value="category"
							action="#{createItemBean.openCategoriesAction}">
						</h:commandButton>
						</td>
					</tr>

					<tr>
						<td><h:outputLabel value="#{msg.item_icon}"></h:outputLabel></td>
						<td>
							<h:graphicImage id="icon_image" value="#{createItemBean.icon}" rendered="#{createItemBean.icon.length() gt 0}"></h:graphicImage>
							<h:inputFile id="icon_file" value="#{createItemBean.iconFile}" onchange="loadBtnOnClick()"/>
							<h:commandButton value="Load" id="load_icon_btn" action="#{createItemBean.loadIconAction}" onclick="return loadIcon()" class="hidden_input">
							</h:commandButton>
						</td>
					</tr>
					
					<tr>
						<td><h:outputLabel value="#{msg.item_attributes}"></h:outputLabel></td>
						<td><h:inputText id="item_attribute" value="#{createItemBean.attribute}"></h:inputText></td>
					</tr>

					<tr class="hidden_input">
						<td><h:outputLabel id="flag_label" value="#{msg.item_suspended }"></h:outputLabel>
						</td>
						<td><h:selectBooleanCheckbox id="item_flag"
								value="#{createItemBean.suspended}">
							</h:selectBooleanCheckbox></td>
					</tr>
					<!-- 
					<tr>
						<td><h:outputLabel value="#{msg.registered_time }"></h:outputLabel>
						</td>
						<td><h:outputLabel value="#{user.registeredTime}">
							</h:outputLabel></td>
					</tr>
					 -->
					<tr>
						<td><h:commandButton value="#{msg.submit}"
								action="#{createItemBean.commitAction }" onclick="return validateForm()">
							</h:commandButton></td>
						<td><h:commandLink value="#{msg.back_to_items}"
								action="#{createItemBean.backToItemsAction }" /></td>
					</tr>

				</table>

			</div>


			<p></p>
			<ui:include src="../footer/footer.xhtml" />

		</body>
	</h:form>
</f:view>
</html>
